﻿using ReservationModule.Classes;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ReservationModule
{
    public partial class StaffDelete : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["Login"] = Session["Login"];
            if (Session["Login"] == "false" || Session["Login"] == null)
            {
                Response.Redirect("Reject.aspx");
            }

            if (Session["StaffType"] == "Receptionist")
            {
                Response.Redirect("Reject.aspx");
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string nric = tbxNRIC.Text;

            Staff s = DBManager.GetStaffByStaffNRIC(nric);
            if (s != null)
            {
                tbxStaffNRIC.Text = s.StaffNRIC1;
                tbxStaffName.Text = s.StaffName1;
                DDLStaffType.Text = s.StaffType1;
                tbxDOB.Text = s.DateOfBirth1.ToString("dddd, MMMM dd, yyyy");
                tbxNationality.Text = s.Nationality1;
                tbxContactNumber.Text = s.ContactNumber1;
                tbxBankNo.Text = s.BankAccountNumber1;
                DDLDutyType.Text = s.DutyType1;
            }
        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("HousekeepingAndStaffMenu.aspx");
        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int delete = DBManager.DeleteStaff(tbxNRIC.Text);
            Response.Redirect("StaffDeleteSuccessful.aspx");
        }
    }
}